home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Informant Complete 1995 - 2000
/
Delphi Informant Complete 1995 to 2000.iso
/
Delphi Informant Magazine Complete Works SOURCE CODE 1995.rar
/
1995
/
JUL
/
BT9507
/
memos.pas
< prev
Wrap
Pascal/Delphi Source File
|
1995-05-19
|
1KB
|
46 lines
unit Memos;
interface
uses WinProcs, SysUtils, StdCtrls, Dialogs, Messages;
{Get the line number and column number the cursor
is positioned at in the memo.}
procedure GetMemoLineCol(Memo: TCustomMemo;
var MemoLine, MemoCol: Integer );
{Set the cursor position in a memo to the specified
line and column.}
procedure MemoCursorTo(Memo: TCustomMemo;
MemoLine, MemoCol: Integer );
implementation
{ Get the line number and column number the cursor
is positioned at in the memo. }
procedure GetMemoLineCol(Memo: TCustomMemo;
var MemoLine, MemoCol: Integer);
begin
with Memo do
begin
{ Get the line number of the line that
contains the cursor. }
MemoLine := SendMessage(Handle, EM_LINEFROMCHAR,
SelStart, 0);
{ Get the offset of the cursor in the line. }
MemoCol := SelStart - SendMessage(Handle, EM_LINEINDEX,
MemoLine, 0) + 1;
end;
end;
{Set the cursor position in a memo to the specified
line and column.}
procedure MemoCursorTo(Memo: TCustomMemo;
MemoLine, MemoCol: Integer );
begin
Memo.SelStart :=
SendMessage(Memo.Handle, EM_LINEINDEX,
MemoLine, 0) + MemoCol - 1;
end;
end.